package com.mrwang.service;

import com.mrwang.mapper.SpecGroupMapper;
import com.mrwang.mapper.SpecParamMapper;
import com.mrwang.pojo.SpecGroup;
import com.mrwang.pojo.SpecParam;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SpecService {
    @Resource
    SpecGroupMapper specGroupMapper;
    @Resource
    SpecParamMapper specParamMapper;

    public List<SpecGroup> groupByCid(Long cid) {
        SpecGroup specGroup = new SpecGroup();
        specGroup.setCid(cid);
        return specGroupMapper.select(specGroup);
    }



    public List<SpecParam> paramList(Long gid,Long cid,Boolean generic,Boolean searching) {
        SpecParam specParam = new SpecParam();
        specParam.setGroupId(gid);
        specParam.setCid(cid);
        specParam.setGeneric(generic);
        specParam.setSearching(searching);
        return specParamMapper.select(specParam);
    }




    public void saveParam(SpecParam specParam) {
        specParamMapper.insertSelective(specParam);
    }

    public void deleteSpecParam(Long id) {
        specParamMapper.deleteByPrimaryKey(id);
    }

    public void updateParam(SpecParam specParam) {
        specParamMapper.updateByPrimaryKeySelective(specParam);

    }


}
